package starComponent.parallelcoordinates;

import starComponent.elements.StarComponent;


/**
 * @author Charles Perin
 * 11 avr. 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 */
public class ParallelLadderTick {

	protected double value;
	protected String label;

	protected int xCenter, yCenter, xLabel, yLabel, xCenterLabel, yCenterLabel;

	public static final int RADIUS = 5;
	protected static final int MARGIN_LABEL = 10;

	protected A_ParallelBranch branch;

	public ParallelLadderTick(A_ParallelBranch branch, double value, String label){
		this.branch = branch;
		setValue(value);
		setLabel(label);
		calculateTickCenter();
		calculateLabelPosition();
	}

	@Override
	public String toString(){
		return "val="+value+", label="+label+", center=("+xCenter+","+yCenter+"), label=("+xLabel+","+yLabel+")";
	}

	protected void calculateTickCenter(){
		xCenter = (int) branch.getX();
		yCenter = (int) (-value*branch.getLength()/branch.getMax()+branch.getyStart());
	}

	private void calculateLabelPosition(){
		
		xLabel = xCenter + label.length()*5+MARGIN_LABEL;
		yLabel = yCenter+StarComponent.LABEL_HEIGHT/2;

	}


	public double getValue() {
		return value;
	}

	public void setValue(double value) {
		this.value = value;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public int getxCenter() {
		return xCenter;
	}

	public void setxCenter(int xCenter) {
		this.xCenter = xCenter;
	}

	public int getyCenter() {
		return yCenter;
	}

	public void setyCenter(int yCenter) {
		this.yCenter = yCenter;
	}

	public int getxLabel() {
		return xLabel;
	}

	public void setxLabel(int xLabel) {
		this.xLabel = xLabel;
	}

	public int getyLabel() {
		return yLabel;
	}

	public void setyLabel(int yLabel) {
		this.yLabel = yLabel;
	}

	public void setxCenterLabel(int xCenterLabel) {
		this.xCenterLabel = xCenterLabel;
	}

	public int getxCenterLabel() {
		return xCenterLabel;
	}

	public void setyCenterLabel(int yCenterLabel) {
		this.yCenterLabel = yCenterLabel;
	}

	public int getyCenterLabel() {
		return yCenterLabel;
	}
}
